<?php 
class ParametersProductsController extends AppController{
	var  $name = "ParametersProducts";
	var $helpers = array('Html','Ajax','Javascript','Form');
	var $paginate = array(
		'limit'=>10,
		'oder'=>array('ParametersProduct.product_id'=>'asc')
		);
	var $uses = array('ParametersProduct','Product','Parameter');
	
	function index($id = null){
		$this->layout = "home";
		$this->ParametersProduct->id = $id;
		$this->set('parametersp',$this->ParametersProduct->read());
		//$this->set('param',$this->ParametersProduct->find('all'));
		
		$this->set('product',$this->Product->find('all'));
		$this->set('parameter',$this->Parameter->find('all'));
		
		$data = $this->paginate('ParametersProduct');
		$this->set('parameterlist',$data);
	}
	function save(){
	$id= $_REQUEST['id'];
	$parameter_id = $_REQUEST['parameter_id'];
	$product_id =$_REQUEST['product_id'];
	$value = $_REQUEST['value'];
	if($id !="" && $id != null){
	$this->ParametersProduct->id= $id;
	$this->ParametersProduct->set('parameter_id',$parameter_id);
	$this->ParametersProduct->set('product_id',$product_id);
	$this->ParametersProduct->set('value',$value);
	$this->ParametersProduct->save();
	}else
	{
		$this->ParametersProduct->create();
		$this->ParametersProduct->set('parameter_id',$parameter_id);
		$this->ParametersProduct->set('product_id',$product_id);
		$this->ParametersProduct->set('value',$value);
		$this->ParametersProduct->saveAll();
	}
	 $this->redirect(array("action" => "index"));
}

function delete() {
		$id= $_REQUEST['id'];
		if($id !=null && $id !=""){
		$this->ParametersProduct->delete($id);
		$this->redirect(array('action'=>'index'));
		}
}
}
?>